package com.nhutcm.sms.Utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import com.nhutcm.sms.Utils.LogUtils.Level;

public class InternetUtils {

	public static boolean isConnectingToInternet(Context context) {
		try {
			ConnectivityManager connectivity = (ConnectivityManager) context
					.getApplicationContext().getSystemService(
							Context.CONNECTIVITY_SERVICE);
			if (connectivity != null) {
				NetworkInfo[] info = connectivity.getAllNetworkInfo();
				if (info != null)
					for (int i = 0; i < info.length; i++)
						if (info[i].getState() == NetworkInfo.State.CONNECTED) {
							return true;
						}

			}
		} catch (Exception e) {
			LogUtils.write(Level.ERROR, e.getMessage());
		}

		return false;
	}
}
